package com.bookstore.backend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bookstore.backend.model.entity.User;
import com.bookstore.backend.model.req.UserListReq;
import org.apache.ibatis.annotations.Mapper;

import java.util.Date;
import java.util.List;

/**
 * @author: world
 * @date: 2022/8/2 14:52
 * @description: bs_user表的持久层
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {
    // 通过注解方式实现
//    @Select("SELECT * FROM `user` WHERE username = #{username} and `password` = #{password}")
    // public User selectByUsernameAndPassword(String username, String password);

    public User selectByUsernameAndPasswordXml(String username, String password);

    // 通过用户名查询
//    @Select("SELECT * FROM `user` WHERE username = #{username}")

    public User selectList(String username, String phone, String email);

    public User selectByUsername(String username);

    public List<User> selectList(UserListReq userListReq);


    //分页
    IPage<User> selectPageVO(Page<User> page, Integer state);

    /**
     * 删除购物车数据
     *
     * @return 受影响的行数
     */
    Integer deleteNumByuid(Integer userId);

    /**
     * 更新购物车数据
     *
     * @return 受影响的行数
     */
    Integer updateNumByuid(User user);

    /**
     * 添加购物车数据
     *
     * @return 受影响的行数
     */
    int insert(User user);

    int signup(String username, String gender, String phone, String email, Date time, String state, String admin,
               String password);
}